package com.testgmaillike.adapter;

import java.util.List;
import java.util.zip.Inflater;

import com.testgmaillike.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ItemAdapter extends BaseAdapter {
	private Context mContext;
	private List<Integer> list;
	private LayoutInflater inflater;
	public ItemAdapter(Context context, List<Integer> list) {
		this.inflater = LayoutInflater.from(context);
		this.list = list;
	}
	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		HolderView holderView = null;

		if (null == convertView) {
			holderView = new HolderView();
			convertView = inflater.inflate(R.layout.item_layout, null);
			
			holderView.titleTextView = (TextView)convertView.findViewById(R.id.title);
			convertView.setTag(holderView);
		}else {
			holderView = (HolderView)convertView.getTag();
		}
		
		Integer integer = list.get(position);
		holderView.titleTextView.setText(integer + "");
		
		return convertView;
	}
	
	private static class HolderView{
		TextView titleTextView;
	} 

}
